//
//  LoginFunctions.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/11.
//

import Foundation

enum BackupsType:String , CaseIterable, Identifiable {
    var id: String {
        self.rawValue
    }
    case local = "local"
    case qiniu = "qiniu"
    case ali = "ali"
}

private let userDefaults = UserDefaults.standard
private let backupsKey = "backupsKey"
var backupsType: BackupsType = .local { // 提供一个初始值
    didSet {
        userDefaults.set(backupsType.rawValue, forKey: backupsKey) // 存储原始值字符串
    }
}

//配置信息
func getDelegateConfig()-> ConfigProtocol? {
    return getDelegateConfig(type : backupsType)
}

//配置信息
func getDelegateConfig(type: BackupsType)-> ConfigProtocol? {
    switch type {
    case .local:
        return ConfigDelegate(instance: LocalConfig())
    case .qiniu:
        return ConfigDelegate(instance: CloudConfig())
    case .ali:
        return ConfigDelegate(instance: AliConfig())
    }
}
